package com.team2.shared;

import android.os.Parcel;
import android.os.Parcelable;

public class Store implements java.io.Serializable,Parcelable
{
	private static final long serialVersionUID = -8180507907726789589L;
	private String id;
	private String brand;
	private String name;
	private String address;
	private String city;
	private String postalCode;
	private String hours;
	private String country;
	private String price;
	private String phone;
	private String distance;
	private double latitude =0.0;
	private double longitude =0.0;
	public Store(){
		
	}
	public Store(ServerStore serverStore){
		this.brand = serverStore.getBrand();
		this.name = serverStore.getName();
		this.address = serverStore.getAddress();
		this.price = serverStore.getPrice();
		this.distance = serverStore.getDistance();
		this.hours = serverStore.getHours();
		
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getBrand() {
		return brand;
	}
	public void setBrand(String brand) {
		this.brand = brand;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getPostalCode() {
		return postalCode;
	}
	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}
	public String getHours() {
		return hours;
	}
	public void setHours(String hours) {
		this.hours = hours;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getDistance() {
		String dString =  String.format("%1$,.3f", Double.parseDouble(distance));
		dString +="km";
		return dString;
	}
	public double getDistranceDouble(){
		double d = Double.parseDouble(distance);
		return d;
	}
	public void setDistance(String distance) {
		this.distance = distance;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	
	@Override
	public int describeContents() {
		return 0;
	}
	@Override
	public void writeToParcel(Parcel out, int flags) {
		// TODO Auto-generated method stub

        out.writeString(id);
        out.writeString(brand);
        out.writeString(name);
        out.writeString(address);
        out.writeString(city);
        out.writeString(postalCode);
        out.writeString(hours);
        out.writeString(country);
        out.writeString(price);
        out.writeString(phone);
        out.writeDouble(latitude);
        out.writeDouble(longitude);
	}
	
	public static final Parcelable.Creator<Store> CREATOR = new Parcelable.Creator<Store>() {
		public Store createFromParcel(Parcel in) {
			return new Store(in);
		}

		public Store[] newArray(int size) {
			return new Store[size];
		}
	};

	private Store(Parcel in) {
		
		id =in.readString();
		brand =in.readString();
		name =in.readString();
		address =in.readString();
		city =in.readString();
		postalCode =in.readString();
		hours=in.readString();
		country=in.readString();
		price = in.readString();
		phone = in.readString();
		latitude = in.readDouble();
		longitude = in.readDouble();

	}
	
}
